import { AfterViewInit, Component, ElementRef, Input, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { NzNotificationService } from 'ng-zorro-antd/notification';

@Component({
  selector: 'app-sign-list',
  templateUrl: './sign-list.component.html',
  styleUrl: './sign-list.component.css'
})
export class SignListComponent implements AfterViewInit, OnDestroy {
  @ViewChild(TemplateRef) template: any;
  @Input() duration = 3000;
  private timer = 0;


  constructor(private notification: NzNotificationService) { }

  createNotification(template: TemplateRef<{}>): void {
    this.notification.template(template, { 
      nzPlacement: 'topLeft',
      nzDuration: this.duration + 10000000
    });
  }

  ngAfterViewInit(): void {
    this.animate()
  }

  ngOnDestroy(): void {
    if (this.timer) {
      clearTimeout(this.timer);
    }
  }

  animate() {
    this.createNotification(this.template)
    // this.timer = window.setTimeout(() => {
    //   this.animate()
    // }, this.duration)
  }

}
